<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html ng-app="app" id="ng-app">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<%@include file="/include/style.jsp"%>
<%@include file="/include/script.jsp"%>
<script type="text/javascript" src="/js/page/enum.js?v=<%=Constants.VERSION %>"></script>
<script type="text/javascript" src="/js/page/driverForm.js?v=<%=Constants.VERSION %>"></script>
<script type="text/javascript">
var DRIVER_ID = '${requestScope.id}';
</script>
</head>
<body ng-controller="DriverCtrl">
<form name="driverForm" class="form-horizontal" ng-submit="saveDriver()" novalidate>
	<legend>
		<span ng-if="mode == 'create'">新增驱动</span>
		<span ng-if="mode == 'update'">修改驱动</span>
	</legend>
	
	<div class="form-container form-horizontal">
		<div class="form-group">
			<label class="col-sm-1 control-label">
				<span class="star-icon">*</span>供应商：
			</label>
			<c:if test="${requestScope.id == null}">
			<div class="col-sm-5" ng-class="(searchStr!=null || driverForm.submited) && !selectedProvider && 'has-error'">
				<angucomplete name="provider" placeholder="输入名称检索供应商" pause="300" selectedobject="selectedProvider"
                  		url="/provider/list?searchstr=" datafield="data" titlefield="name" descriptionfield="description" minlength="1" inputclass="form-control" matchclass="highlight" required />
			</div>
			</c:if>
			<c:if test="${requestScope.id != null}">
			<div class="col-sm-5">
				<div style="font-weight:bold;" ng-bind="editingDriver.provider.name"></div>
				<div style="color:gray;font-size:12px;line-height:20px;" ng-bind="editingDriver.provider.description"></div>
			</div>
			</c:if>
		</div>
		
		<div class="form-group">
			<label class="col-sm-1 control-label">
				<span class="star-icon">*</span>类型：
			</label>
			<div class="col-sm-2" ng-class="(driverForm.type.$dirty || driverForm.submited) && driverForm.type.$invalid && 'has-error'">
				<select class="form-control" ng-model="editingDriver.type" ng-options="option for option in DRIVER_TYPE" name="type" required></select>
			</div>
			<label class="col-sm-1 control-label">
				<span class="star-icon">*</span>验证算法：
			</label>
			<div class="col-sm-2" ng-class="(driverForm.algorithm.$dirty || driverForm.submited) && driverForm.algorithm.$invalid && 'has-error'">
				<select class="form-control" ng-model="editingDriver.algorithm" ng-options="option for option in DRIVER_ALGORITHM" name="algorithm" required></select>
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-1 control-label">
				<span class="star-icon">*</span>驱动名称：
			</label>
			<div class="col-sm-5" ng-class="(driverForm.name.$dirty || driverForm.submited) && driverForm.name.$invalid && 'has-error'">
				<input type="text" class="form-control" ng-model="editingDriver.name" name="name" maxlength="100" autocomplete="off" required/>
				<span class="text-danger" ng-if="driverForm.name.$dirty && driverForm.name.$invalid">
					<span ng-if="driverForm.name.$error.duplicated">驱动重复</span>
				</span>
			</div>
		</div>
		
		<div class="form-group">
			<div class="col-sm-offset-1">
				<button type="submit" class="btn btn-success"> <i class="fa fa-check-circle"></i> 保存 </button>
				<button type="button" class="btn btn-default" ng-click="backPage()">取消</button>
			</div>
		</div>
	</div>
</form>
</body>
</html>